﻿<!--
 Peter
 Created by: Peter Development Team
    http://peter.codeplex.com/
 
 GNU General Public License version 2 (GPLv2)
    http://peter.codeplex.com/license

 This code is provided on an AS IS basis, with no WARRANTIES,
 CONDITIONS or GUARANTEES of any kind.
-->
<UserControl x:Class="Peter.View.ViewWorkspace"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:controls="clr-namespace:Peter.Common.Controls;assembly=Peter.Common"
             xmlns:logic="clr-namespace:Peter.Logic"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:common="clr-namespace:Peter.Common;assembly=Peter.Common"
             xmlns:mvvm="clr-namespace:Peter.Common.Tree;assembly=Peter.Common"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance Type=logic:ModelWorkspace}"
             d:DesignHeight="300" d:DesignWidth="300">
   <Grid>
      <controls:TreeViewEx SelectedTreeItem="{Binding Path=SelectedItem, Mode=TwoWay}"
                           ItemsSource="{Binding Path=Projects}"
                           ExecuteCommand="{Binding Path=ExecuteCommand}"
                           ContextMenu="{Binding Path=ContextMenu}">

         <TreeView.Resources>
            <HierarchicalDataTemplate DataType="{x:Type common:PeterProject}"
                                      ItemsSource="{Binding Path=Children}">
               <StackPanel Orientation="Horizontal"
                           VerticalAlignment="Center">
                  <icons:IconDisplay IconSize="Medium"
                                     Margin="0,0,3,0"
                                     Icon="{Binding Path=Icon}" />
                  <TextBlock Text="{Binding Path=ProjectName}"
                             x:Name="_HeaderText"
                             VerticalAlignment="Center"
                             Margin="0, 0, 5, 0" />
               </StackPanel>
               <HierarchicalDataTemplate.Triggers>
                  <DataTrigger Binding="{Binding Path=IsCurrentProject}"
                               Value="True">
                     <Setter Property="FontWeight"
                             TargetName="_HeaderText"
                             Value="Bold" />
                  </DataTrigger>
               </HierarchicalDataTemplate.Triggers>
            </HierarchicalDataTemplate>
            
            <HierarchicalDataTemplate DataType="{x:Type mvvm:ModelTreeViewItem}"
                                      ItemsSource="{Binding Path=Children}">
               <StackPanel Orientation="Horizontal"
                           VerticalAlignment="Center">
                  <icons:IconDisplay IconSize="Medium"
                                     Margin="0,0,3,0"
                                     Icon="{Binding Path=Icon}" />
                  <TextBlock Text="{Binding Path=Text}"
                             VerticalAlignment="Center"
                             Margin="0, 0, 5, 0" />
               </StackPanel>
            </HierarchicalDataTemplate>

         </TreeView.Resources>
      </controls:TreeViewEx>
   </Grid>
</UserControl>
